package com.ieng.kican.common.utils.context;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * HttpServlet 工具类
 * </p>
 *
 * @author IENG
 */
public class ServletUtils {

    public static HttpServletRequest request() {
        return getRequestAttributes().getRequest();
    }

    public static HttpServletResponse response() {
        return getRequestAttributes().getResponse();
    }

    public static ServletRequestAttributes getRequestAttributes() {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        return (ServletRequestAttributes) attributes;
    }

}
